<template>
  <el-row>
    <el-col :span="3" class="headImg">
      <img :src="record.to.uid === user.uid?(imgUrl+from.img):''"/>
    </el-col>

    <el-col :span="18" class="msg">
      <el-card 
        class="inline"
        :style="{float: record.from.uid === user.uid?'right':'left'}"
        :body-style="{
          background: record.from.uid === user.uid?'rebeccapurple':'white',
          color: record.from.uid === user.uid?'white':'gray',
          'text-align': record.from.uid === user.uid?'right':'left',
          display: 'inline-block',
          'height': '16px',
          'line-height': '16px'
        }"
      >{{ record.msg }}</el-card>
    </el-col>

    <el-col :span="3" class="headImg">
      <img class="userImg" :src="record.from.uid === user.uid?(imgUrl+user.img):''">
    </el-col>
  </el-row>
</template>

<script>
export default {
  props: [
    'from','user','record'
  ],
  data() {
    return {
      imgUrl: 'http://123.57.249.44/imgs/',
    }
  },
}
</script>

<style lang="scss" scoped>
  .headImg {
    img {
      border-radius: 5px;
      height: 60px;
      margin-top: 10px;
    }
    .userImg {
      float: right;
    }
  }

  .msg {
    margin-top: 10px;
    display: inline;
    .inline {
      display: inline-block;
    }
  }

  @media screen and (max-width: 750px) {
    .headImg {
      img {
        height: 45px;
      }
      .userImg {
        transform: translateY(-2px);
      }
    }
  }
</style>